<?php

namespace app\user\controller;
use app\admin\controller\Message;
use think\Controller;
use think\Db;
use think\Session;

require EXTEND_PATH.'/SendSMS_al/api_demo/SmsDemo.php';
class SendSMS extends Controller
{
    //
    /**
     * @param $tel
     * @return mixed
     */
    public function SendSMS1($tel)
    {
        $res=Db::name('user')->where('tel',$tel)->select();
        if($res){
            $data['Message']='该手机号已注册';

            return $data;
        }
        $telcode=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
        Session::set('temp.telcode',$telcode);
//        return (Session::get());
//        require EXTEND_PATH.'/SendSMS/SendTemplateSMS.php';
//        $res=sendTemplateSMS($tel,array($telcode,'30'),"1");
//        return $res;

        header('Content-Type: text/plain; charset=utf-8');

        $response = \SmsDemo::sendSms($tel,$telcode,'SMS_133895115');
//        echo "发送短信(sendSms)接口返回的结果:\n";
        return $response;
//        var_dump($response);
//        {Message: "OK", RequestId: "8F0A2F86-7646-4BF4-990E-4094011745B9", BizId: "250614224800597340^0", Code: "OK"}
    }
    public function SendSMS2($tel)
    {
        $res=Db::name('user')->where('tel',$tel)->select();
        if($res){
            $data['Message']='该手机号已注册';

            return $data;
        }
        $telcode=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
        Session::set('temp.telcode',$telcode);
//        return (Session::get());
//        require EXTEND_PATH.'/SendSMS/SendTemplateSMS.php';
//        $res=sendTemplateSMS($tel,array($telcode,'30'),"1");
//        return $res;

        header('Content-Type: text/plain; charset=utf-8');

        $response = \SmsDemo::sendSms($tel,$telcode,'SMS_133915126');
//        echo "发送短信(sendSms)接口返回的结果:\n";
        return $response;
//        var_dump($response);
//        {Message: "OK", RequestId: "8F0A2F86-7646-4BF4-990E-4094011745B9", BizId: "250614224800597340^0", Code: "OK"}
    }
    public function SendSMS3($tel)
    {
        $res=Db::name('user')->where('tel',$tel)->select();
        if(!$res){
            $data['Message']='该手机号没有注册';

            return $data;
        }
        $telcode=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
        Session::set('temp.telcode',$telcode);
//        return (Session::get());
//        require EXTEND_PATH.'/SendSMS/SendTemplateSMS.php';
//        $res=sendTemplateSMS($tel,array($telcode,'30'),"1");
//        return $res;

        header('Content-Type: text/plain; charset=utf-8');

        $response = \SmsDemo::sendSms($tel,$telcode,'SMS_133890074');
//        echo "发送短信(sendSms)接口返回的结果:\n";
        return $response;
//        var_dump($response);
//        {Message: "OK", RequestId: "8F0A2F86-7646-4BF4-990E-4094011745B9", BizId: "250614224800597340^0", Code: "OK"}
    }
}
